package com.example.administrator.swredeem.utils;

import android.app.Activity;
import android.content.Context;
import android.util.Base64;
import android.util.DisplayMetrics;
import android.view.WindowManager;

import com.example.administrator.swredeem.appBase.Config;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;



public class Utils {
    /**
     * @Description: 根据图片地址转换为base64编码字符串
     * @Author:
     * @CreateTime:
     * @return
     */
    //图片转化成base64字符串
    public static String GetImageStr( String imageFile)
    {//将图片文件转化为字节数组字符串，并对其进行Base64编码处理
        String imgFile = imageFile;//待处理的图片
        InputStream in = null;
        byte[] data = null;
        //读取图片字节数组
        try
        {
            in = new FileInputStream(imgFile);
            data = new byte[in.available()];
            in.read(data);
            in.close();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        //对字节数组Base64编码
        Base64Encoder encoder = new Base64Encoder();
        return encoder.encode(data);//返回Base64编码过的字节数组字符串
//        return null;
    }


}
